﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using IHISCETeim.BLL;
using IHISCETeim.Library;
using IHISCETeim.Model;
using System.Data;
using System.Text;

namespace IHISCETeim.Web.MachineSys.PartsModel
{
    public partial class PartsBalanceAddAdjusting : PageBase
    {
        protected override string DWZRef
        {
            get
            {
                return "PartsDebtList";
            }
        }

        protected override Permission[] PowerKey
        {
            get
            {
                return new Permission[] { Permission.应收帐款_冲帐 };
            }
        }

        protected int BID
        {
            get
            {
                return GetRequestValue<int>("BID", 0);
            }
        }

        protected PartsBalanceInfo _objShow = null;
        protected PartsBalanceInfo objShow
        {
            get
            {
                if (_objShow == null)
                    _objShow = PartsBalanceController.GetList(BID);

                return _objShow;
            }
        }


        protected void Page_Load(object sender, EventArgs e)
        {
            if (GetRequestValue<string>("ajaxmethod", "") == "edit")
            {
                addmenu();

            }
        }
        private void addmenu()
        {

            decimal NewBalanceMoney = GetRequestValue<decimal>("BalanceMoney",0);

            int id = PartsBalanceController.AddAdjusting(BID,NewBalanceMoney);
            if (id>0)
            {
                //跳转参数
                //string msg = "已成功收款,进入冲帐界面...";
                //string tabTitle = "冲帐";
                //string taburl = "FTradeModel/FTradeBalanceAdd.aspx?FCatheringId=" + id.ToString();
                //string tabrelId = "FTradeBalanceAdd";
                //SuccessDialogOpenNavTab(msg, tabTitle, taburl, tabrelId);
                SuccessJson("已成功调帐");
            }
            else
            {
                if(id==-99)
                    ErrorJson("调帐失败,调帐金额必需小于原来的充帐金额");
            }

        }
    }
}